﻿#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
//int main()
//{
//    int a = 0x11223344;
//    char* pc = (char*)&a;
//    *pc = 0;
//    printf("%x\n", a);
//    return 0;
//}
//int main()
//{
//    unsigned char a = 200;
//    //00000000000000000000000011001000
//    //11001000 ->a
//    unsigned char b = 100;
//    //00000000000000000000000001100100
//    //01100100 ->b
//    unsigned char c = 0;
//    //00000000000000000000000000000000
//    //00000000 ->c
//    c = a + b;
//    //00101100 ->c
//    //11111111111111111111111100101100
//    printf(" %d %d", a + b, c);
//    return 0;
//}
//写一个函数判断当前机器是大端还是小端，如果是小端返回1，如果是大端返回0.
//int main()
//{
//	int n = 1;
//	int ret = *(char*)&n;
//	if (ret == 0)
//		printf("大端");
//	else
//		printf("小端");
//}
//int strncmp ( const char * str1, const char * str2, size_t num );
//int my_strncmp(const char* str1, const char* str2, size_t num)
//{
//	while (num--)
//	{
//		str1++;
//		str2++;
//	}
//	return *str1 - *str2;
//}
//int main()
//{
//	char str1[] = "abcdef";
//	char str2[] = "abcccf";
//	int ret = my_strncmp(str1, str2, 2);
//	printf("%d", ret);
//	return 0;
//}
//模拟实现strncpy
// char * strncpy ( char * destination, const char * source, size_t num );
//拷⻉num个字符从源字符串到⽬标空间。
//如果源字符串的⻓度⼩于num，则拷⻉完源字符串之后，在⽬标的后边追加0，直到num个。
//char *my_strncpy(char* dest, const char* sor, size_t num)
//{
//	while (num--)
//	{
//		*dest++ = *sor++;
//	}
//	*dest = '\0';
//}
//int main()
//{
//	char dest[20] = { "gsdfgsdfhg" };
//	char sor[] = "abcdef";
//	my_strncpy(dest, sor, 4);
//	printf("%s", dest);
//	return 0;
//}
//模拟实现strncat
//char * strncat ( char * destination, const char * source, size_t num )
char* my_strncat(char* dest, const char* sour, size_t num)
{
	while (*dest)
	{
		dest++;
	}
	while (num--)
	{
		*dest++ = *sour++;
	}
}
int main()
{
	char dest[10] = { "I "};
	char sour[] = "come go";
	my_strncat(dest, sour, 6);
	printf("%s",dest);
}